extends Node2D

var windows_wide
var windows_high
var windows_position_X
var windows_position_Y
var mouse_position_x
var mouse_position_y
var player_position_x
var player_position_y
var mouse_rotate
@onready var sprite_2d = $Sprite2D
var start_rotation
# Called when the node enters the scene tree for the first time.
func _ready():
	start_rotation=sprite_2d.rotation
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	windows_wide=DisplayServer.window_get_size().x
	windows_high=DisplayServer.window_get_size().y
	windows_position_X=DisplayServer.window_get_position().x
	windows_position_Y=DisplayServer.window_get_position().y
	mouse_position_x=DisplayServer.mouse_get_position().x
	mouse_position_y=DisplayServer.mouse_get_position().y

	player_position_x=windows_position_X+windows_wide/2
	player_position_y=windows_position_Y+windows_high/2

	mouse_rotate=atan2((mouse_position_y-player_position_y),(mouse_position_x-player_position_x))
	sprite_2d.rotation=start_rotation+mouse_rotate
	#print(start_rotation)
	#print(mouse_rotate)
	#获取窗口大小
	#print(DisplayServer.window_get_size())
	#获取窗口左上角位置
	#print(DisplayServer.window_get_position())
	#获取整个屏幕上鼠标的位置
	#print(DisplayServer.mouse_get_position())
	#获取鼠标速度
	#print(Input.get_last_mouse_velocity()) 
	pass

